using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Department;

namespace TrainingManagement.api.Models.BusinessLogic.Department
{
    public class DepartmentCreateOperation : BusinessOperation<BusinessObjects.Department, BusinessObjects.Department>
    {
        readonly DepartmentInsertDataSource _departmentInsert = new DepartmentInsertDataSource();

        public override BusinessObjects.Department Run(BusinessObjects.Department input)
        {
            if (_departmentInsert.Execute(input))
                return input;
            throw new Exception(string.Format("{0} was not saved!", input.Title));
        }
    }
}